package cn.zf233.jwtshiro.web;

import cn.zf233.jwtshiro.common.R;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by zf233 on 2021/7/12
 */
@RequestMapping("/test")
@RestController
public class TestController extends BaseController {

    @GetMapping("/hello")
    public R<String> hello() {
        return R.createBySuccessMessage("无权限角色访问成功");
    }

    @RequiresRoles(value = {"user", "admin"}, logical = Logical.OR)
    @GetMapping("/user")
    public R<String> user() {
        return R.createBySuccessMessage("user角色访问成功");
    }

    @RequiresRoles(value = {"admin"})
    @GetMapping("/admin")
    public R<String> admin() {
        return R.createBySuccessMessage("admin角色访问成功");
    }

    @RequiresPermissions(value = {"insert"})
    @GetMapping("/insert")
    public R<String> insert() {
        return R.createBySuccessMessage("insert权限访问成功");
    }

    @RequiresPermissions(value = {"update"})
    @GetMapping("/update")
    public R<String> update() {
        return R.createBySuccessMessage("update权限访问成功");
    }

    @RequiresPermissions(value = {"remove"})
    @GetMapping("/remove")
    public R<String> remove() {
        return R.createBySuccessMessage("remove权限访问成功");
    }

    @RequiresPermissions(value = {"select"})
    @GetMapping("/select")
    public R<String> select() {
        return R.createBySuccessMessage("select权限访问成功");
    }
}
